package controllers

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

//环境验证器，防止传入不存在环境
type EnvController struct {
}

func NewEnvController() *EnvController {
	return &EnvController{}
}

//验证环境
func (ctl EnvController) AuthEnv(c *gin.Context) {
	env := c.Param("env")
	if env == "1" {
		c.Set("env", "test")
	} else if env == "3" {
		c.Set("env", "online")
	} else if env == "4" {
		c.Set("env", "aliyun")
	} else {
		c.AbortWithStatus(http.StatusForbidden)
		c.String(http.StatusForbidden, "do not exist env")
		return
	}

}
